using System;
using UnityEngine;
using UnityEngine.UI;

namespace CGF
{
    //该脚本自动生成或覆盖，不可编辑
    public partial class PanelVIPRule
    {   
		public Image Dialog;
		public CButton BtnClose;
		public Slider LevelProgress;
		public ImagePro Point0;
		public ImagePro Point1;
		public ImagePro Point2;
		public ImagePro Point3;
		public ImagePro Point4;
		public Text Text0;
		public Text Text1;
		public Text Text2;
		public Text Text3;
		public Text Text4;
		public I18N i18n;

        public Reference reference { get; private set; }
        public Action onProsBindCompleted;
        public bool isProsBindCompleted;
        
        public void BindProperties(Transform transform)
        {   
            reference = transform.GetComponent<Reference>();
            if(!reference)return;
            int nodeIndex = 0;
			Dialog = (reference.nodes[nodeIndex++].obj as GameObject).GetComponent<Image>();
			BtnClose = (reference.nodes[nodeIndex++].obj as GameObject).GetComponent<CButton>();
			LevelProgress = (reference.nodes[nodeIndex++].obj as GameObject).GetComponent<Slider>();
			Point0 = (reference.nodes[nodeIndex++].obj as GameObject).GetComponent<ImagePro>();
			Point1 = (reference.nodes[nodeIndex++].obj as GameObject).GetComponent<ImagePro>();
			Point2 = (reference.nodes[nodeIndex++].obj as GameObject).GetComponent<ImagePro>();
			Point3 = (reference.nodes[nodeIndex++].obj as GameObject).GetComponent<ImagePro>();
			Point4 = (reference.nodes[nodeIndex++].obj as GameObject).GetComponent<ImagePro>();
			Text0 = (reference.nodes[nodeIndex++].obj as GameObject).GetComponent<Text>();
			Text1 = (reference.nodes[nodeIndex++].obj as GameObject).GetComponent<Text>();
			Text2 = (reference.nodes[nodeIndex++].obj as GameObject).GetComponent<Text>();
			Text3 = (reference.nodes[nodeIndex++].obj as GameObject).GetComponent<Text>();
			Text4 = (reference.nodes[nodeIndex++].obj as GameObject).GetComponent<Text>();
			i18n = transform.GetComponent<I18N>();
            isProsBindCompleted = true;
            onProsBindCompleted?.Invoke();
        }
        
        public void SetProsBindCompletedAction(Action action)
        {
            if (isProsBindCompleted)
            {
                action?.Invoke();
            }
            else
            {
                onProsBindCompleted = action;
            }
        }

		public string I18N_get_discount { get { return i18n.GetTextByKey("get_discount"); } }
		public string I18N_lease_amount_to { get { return i18n.GetTextByKey("lease_amount_to"); } }
    }
}
